package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2018/12/24 15:18
 * @description
 */
public class Code806 {
    public int[] numberOfLines(int[] widths, String S) {
        int[] result = new int[2];
        int total = 0;
        for (char c : S.toCharArray()) {
            if (total + widths[c - 97] > 100) {
                result[0]++;
                total = widths[c - 97];
            } else {
                total += widths[c - 97];
            }
        }
        result[1] = total;
        if (total != 0) { result[0]++; }
        return result;
    }
}
